package com.liang.service.impl;


import com.liang.mapper.DutyzxDAO;
import com.liang.mapper.DutyzxarmyxDAO;
import com.liang.pojo.Armyx;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import com.liang.mapper.ArmyxDAO;
import javax.annotation.Resource;

import com.liang.pojo.Dutyzx;
import com.liang.pojo.dto.ArmyDutyxz;
import com.liang.pojo.dto.ArmyDutyxzUserUse;
import com.liang.pojo.dto.ArmyxTreex;
import com.liang.utils.DateUtils;
import org.springframework.stereotype.Service;
import com.liang.service.ArmyxService;
/**
 *@作者:lsk
 *Service实现类
 *@Date:2023/10/16
*/
@Service
public class ArmyxServiceImpl  implements ArmyxService{


	@Resource
	private ArmyxDAO armyxdao;

	@Resource
	private DutyzxDAO dutyzxDAO;


	/**
	根据Army_id查询
	*/
	public Object selectByArmy_id(Long army_id){
		return armyxdao.selectByArmy_id(army_id);
	}


	/**
	根据Army_id更新
	*/
	public Integer updateByArmy_id(Armyx demo){
		return armyxdao.updateByArmy_id( demo);
	}



	/**
	根据Army_id删除
	*/
	public Integer deleteByArmy_id(Long army_id){

		return armyxdao.deleteByArmy_id(army_id);
	}

	/**
	 * 查询军队的职务
	 */
	@Override
	public List<ArmyDutyxz> ArmyAndAllDutyxz(Map param) {
		if(param.get("pageNum") != null){
			int start = Integer.parseInt(param.get("pageSize").toString()) * (Integer.parseInt(param.get("pageNum").toString()) - 1);
			param.put("pageNum",start);
		}
		return armyxdao.ArmyAndAllDutyxz(param);
	}

	/**
	 * 查询军队的职务,并且查看职务是否有人任职
	 */
	@Override
	public List<ArmyDutyxzUserUse> selectArmyDutyUserUser(Map param) {
		if(param.get("pageNum") != null){
			int start = Integer.parseInt(param.get("pageSize").toString()) * (Integer.parseInt(param.get("pageNum").toString()) - 1);
			param.put("pageNum",start);
		}
		return armyxdao.selectArmyDutyUserUser(param);
	}


	/**
	 insert:(插入)
	*/
	public Object insert(Armyx demo){
		demo.setCreate_time(DateUtils.getTodayDateTime());
		armyxdao.insertlsk(demo);
		return demo;
	}

	/**
	 * 查询军队和他的一个子军队是否有
	 */
	@Override
	public List<ArmyxTreex> selectListAllArmy(Map<String, Object> param) {
		if(param.get("pageNum") != null){
			int start = Integer.parseInt(param.get("pageSize").toString()) * (Integer.parseInt(param.get("pageNum").toString()) - 1);
			param.put("pageNum",start);
		}
		return armyxdao.selectListAllArmy(param);
	}


	/**
	 insertOrUpdate(插入或更新(根据主键或唯一索引更新，主键和唯一索引不会改变))
	*/
	public Integer insertOrUpdate(Armyx demo){
		demo.setUpdate_time(DateUtils.getTodayDateTime());
		return armyxdao.insertOrUpdatelsk(demo);
	}



	/**
	 insertBath:(批量插入)
	*/
	public Integer insertBatch(List<Armyx> list){
		return armyxdao.insertBatchlsk(list);
	}



	/**
	 insertOrUpdateBatch:(批量插入或更新)
	*/
	public Integer insertOrUpdateBatch(List<Armyx> list){
		return armyxdao.insertOrUpdateBatchlsk(list);
	}



	/**
	 selectList:(根据参数查询集合)
	*/
	public List<Armyx> selectList(Map<String,Object> param){
		if(param.get("pageNum") != null){
			int start = Integer.parseInt(param.get("pageSize").toString()) * (Integer.parseInt(param.get("pageNum").toString()) - 1);
			param.put("pageNum",start);
		}
		return armyxdao.selectListlsk(param);
	}



	/**
	 selectCount:(根据集合查询数量)
	*/
	public Long selectCount(Map<String,Object> param){
		return armyxdao.selectCountlsk(param);
	}



}